FROM alpine:3.12.12
RUN addgroup www \
&& adduser -G www -D -s /sbin/nologin www \
&& sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories \
&& apk --update add --no-cache nginx php7-pdo_mysql php7-fpm \
&& mkdir -p /run/nginx \
&& mkdir -p /var/run/php \
&& mkdir -p /var/www/html \
&& sed -i '/a 404/a\\troot /var/www/html;\n \
\tlocation ~ \\.php$ {\n \
\t\tfastcgi_pass 127.0.0.1:9000;\n \
\t\tfastcgi_index index.php;\n \
\t\tfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n \
\t\tinclude fastcgi_params;\n \
\t\tssi on;\n \
\t\tssi_silent_errors on;\n \
\t\tssi_types text/html;\n \
\t}' /etc/nginx/conf.d/default.conf \
&& sed -i '/404;/c\ \
\t\ttry_files $uri $uri/ =404;\n \
\t\tssi on;\n \
\t\tssi_silent_errors on;\n \
\t\tssi_types text/html;' /etc/nginx/conf.d/default.conf \
&& echo -e '#! /bin/sh\n/usr/sbin/php-fpm7\n/usr/sbin/nginx -c /etc/nginx/nginx.conf\nwhile true\ndo\n\tsleep 60\ndone' > /usr/local/bin/start.sh \
&& chmod +x /usr/local/bin/start.sh
EXPOSE 80
